const Router = require('koa-router')
const auth = require('@/middleware/auth')
const { 
  saveDic, deleteDic, getDictByCode,
  getDictCategories, getDicListAll, saveDictCategory, deleteDictCategory } = require('@/controller/dictionary')

const menuRouter = new Router({ prefix: '/dictionary' })

menuRouter.get('/list', auth, getDictCategories) // 获取字典列表(分类)
menuRouter.get('/listAll', auth, getDicListAll) // 获取字典列表(全部)
menuRouter.get('/item/list', auth, getDictByCode) // 获取字典项列表
menuRouter.post('/save', auth, saveDic) // 保存字典
menuRouter.post('/delete', auth, deleteDic) // 删除字典

menuRouter.get('/categories', auth, getDictCategories) // 获取字典分类列表
menuRouter.post('/saveCategory', auth, saveDictCategory)
menuRouter.post('/deleteCategory', auth, deleteDictCategory)

module.exports = menuRouter
